//
//  BaseTableViewController.swift
//  Weibo
//
//  Created by 杨雨哲 on 15/6/24.
//  Copyright © 2015年 yyz. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    var userLogon = sharedUserAccount != nil
    
    var visitorView : VisitorLoginView?

    override func loadView() {

        userLogon ? super.loadView() : setupVisitorView()
        
    }
    
    private func setupVisitorView(){
        
        visitorView = VisitorLoginView()
        
        visitorView?.delegate = self
        
        view = visitorView!
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClicked")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClicked")
    }
    
    func visitorRegisterButtonClicked() {
        print("注册")
    }
    
    func visitorLoginButtonClicked() {
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        
        // 对于独立的视图控制器，可以使用 modal 展现
        presentViewController(nav, animated: true, completion: nil)
    }

    
}